#ifndef __IMU_MATH_H
#define __IMU_MATH_H

#ifdef __cplusplus
extern "C"{
#endif

#include "math.h"

#define RAD_TO_DEG 57.295779513082320876798154814105

typedef struct
{
  float yaw;
  float pitch;
  float roll;
}imu_euler;

typedef struct
{
  float x;
  float y;
  float z;
}imu_vector3f;

typedef struct
{
  float q0;
  float q1;
  float q2;
  float q3;

}imu_vector4f;

/********************全局函数声明********************/
void imu_math_raw_to_quaternion(imu_vector3f *gyro,imu_vector3f *accel,double freq,imu_vector4f* quater);
void quaternion_to_euler(imu_vector4f* quater, imu_euler* euler);

/*数学*/

float imu_math_cal_euler_error(const float target,float real);
imu_vector3f vector_sub(imu_vector3f a,imu_vector3f b);
float inv_sqrt(float x);
float sq(float v);

#ifdef __cplusplus
}
#endif

#endif
